<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'category-form',
	'enableAjaxValidation'=>false,
)); ?>

	<p class="note">Fields with <span class="required">*</span> are required.</p>

	<?php echo $form->hiddenField($model, 'parent_id', array('id'=>'iptParentId',)); ?>

	<div class="row">
		<div class="info">
		<b>Parent category</b> (<a href='#' onclick="jQuery('#divSuggestedCat').toggle('slow'); return false;"><em>Change</em></a>) <br>
		<p class="note" id="divParentInfo">
			<?php if ($parentModel) {?>

			Root &nbsp;&raquo;&nbsp;
			<?php
				foreach ($parentModel->path as $e) {
					echo CHtml::link($e->name, $this->createUrl('view', array('id'=>$e->id)));
					echo '&nbsp;&raquo;&nbsp';
				}
				echo CHtml::link($parentModel->name, $this->createUrl('view', array('id'=>$parentModel->id)));
			?>
			<?php } else { ?>
			This is root category.
			<?php } ?>
		</p>
		</div>

		<div class="suggest" id="divSuggestedCat" style="display: none;">
			<?php echo $this->renderPartial('_suggested_cats', array('model'	=>	$fModel)) ; ?>
		</div>
	</div>

	<?php echo $form->errorSummary($model); ?>

	<hr>
	
	<div class="row">
		<?php echo $form->labelEx($model,'name'); ?>
		<?php echo $form->textField($model,'name',array('size'=>45,'maxlength'=>45)); ?>
		<?php echo $form->error($model,'name'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'url_key'); ?>
		<?php echo $form->textField($model,'url_key',array('size'=>45,'maxlength'=>45)); ?>
		<?php echo $form->error($model,'url_key'); ?>
	</div>
    
    
    <div class="row" style="display: none;">
        <?php echo $form->labelEx($model,'last_updated_time'); ?>
        <?php echo $form->textField($model,'last_updated_time',array('value'=>date('Y-m-d G:i:s'))); ?>
        <?php echo $form->error($model,'last_updated_time'); ?>
    </div>

	<div class="row">
		<?php echo $form->labelEx($model,'enable'); ?>
		<?php echo $form->radioButtonList($model,'enable', array(
			'1'	=>	"Yes",
			'0'	=>	'No',
		)); ?>
		<?php echo $form->error($model,'enable'); ?>
	</div>

	<div class="row buttons">
		<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
	</div>

<?php $this->endWidget(); ?>

</div><!-- form -->

<script language="JavaScript">
<!--
jQuery(function($) {
	$('#divParentInfo')[0].setParentCatInfo = function(id, html) {
		$('#iptParentId').val(id);
		var div = $('#divParentInfo');
		div[0].newHtml = html;
		div.fadeOut('slow', function() {
			$(this).html(this.newHtml);
			$(this).fadeIn();
		});
		$('#divSuggestedCat').toggle('slow');
	};
});
//-->
</script>